﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_ControlApprovePhanTuyen : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           
        }
        else
        {
            LoadFinalPivotResult();
        }
    }
   
    protected void btnView_Click(object sender, EventArgs e)
    {
        LoadFinalPivotResult();
    }
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        dt = new ClassExecute.ClassExecute();
        try
        {
            bool kq = dt.ExecuteSQl_bool(str, CommandType.StoredProcedure, "k_ApprovePhanTuyen", ref error,
                new SqlParameter("@Username", Session["user"].ToString()));
            if (kq)
            {
                ShowMessageBox("Bạn đã approve thành công cho việc phân tuyến TDV");
            }
            else
            {
                ShowMessageBox("Hệ thống đang bảo trì");
            }

        }
        catch
        {
        }
    }
    protected void ImgBtnPivot_Click(object sender, ImageClickEventArgs e)
    {
        
    }
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        
    }
    void LoadFinalPivotResult()
    {
        dt = new ClassExecute.ClassExecute();
        try
        {
            DataTable db = dt.Get_Data_DataTable(str, ref error, "[k_getPivotSetiingForApprove]", CommandType.StoredProcedure);
            if (db.Rows.Count > 0)
            {

                ASPxPivotGrid1.DataSource = db;

            }
            else
            {

                ASPxPivotGrid1.DataSource = null;
            }
            ASPxPivotGrid1.DataBind();
        }
        catch (Exception ex)
        {
            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }
    }
    void ShowMessageBox(string text)
    {
        MessageBox.Text = text;
        MessageBox.ShowOnPageLoad = true;
    }
}